package com.mdjnu.controller;

import com.mdjnu.pojo.Comment;
import com.mdjnu.pojo.Result;
import com.mdjnu.service.CommentService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
// 评论控制类
public class CommentController {
    //评论服务
    @Autowired
    // 注入service
    private CommentService commentService;
    //添加评论
    @PostMapping
    public Result addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }
    //根据视频id查询评论
    @GetMapping
    public Result findByVideoId(@Param("videoId") int videoId, @Param("pageNum") int pageNum, @Param("pageSize") int pageSize){
        return commentService.findByVideoId(videoId,pageNum,pageSize);
    }
}
